package br.ufrj.dcc.xml.dynamicintervals.vo;


public class Item implements Comparable<Item>{
	
	public static final int ELEMENT = 1;
	public static final int ATTRIBUTE = 2;
	public static final int ATTRIBUTEVALUE = 3;
	public static final int DATA = 4;
	public static final int PROCESSINGINSTRUCTION = 5;
	
	private String data;
	private int l;
	private int r;
	private int type;
	
	
	private boolean hasElementChildren;
	private boolean hasDataChildren;
	/**
	 * One item is smaller than the other when it's l value is smaller.
	 */
	public int compareTo(Item o) {
		if ( l < o.l )
			return -1;
		return 1;
	}
	
	/* For debugging only. This function cuts whitespace, and 
	 * although it's very convenient for debugging purposes, it's
	 * not valid.
	 * */
	@Override
	public String toString() {
		String data = this.data/*.trim()*/;
		if (type == ELEMENT)
			data = '<' + data + '>';
		else if (type == ATTRIBUTE)
			data = '@' + data;
		return '\''+data + "' | " + l + " | " + r;
	}

	public String getData() {
		return data;
	}

	public void setData(String data) {
		this.data = data;
	}

	public int getL() {
		return l;
	}

	public void setL(int l) {
		this.l = l;
	}

	public int getR() {
		return r;
	}

	public void setR(int r) {
		this.r = r;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public boolean isHasDataChildren() {
		return hasDataChildren;
	}

	public void setHasDataChildren(boolean hasDataChildren) {
		this.hasDataChildren = hasDataChildren;
	}

	public boolean isHasElementChildren() {
		return hasElementChildren;
	}

	public void setHasElementChildren(boolean hasElementChildren) {
		this.hasElementChildren = hasElementChildren;
	}


}
